@extends('layout.master')

@section('title','商户详情')

@section('css')
    @parent
    <style>
        .form-material .form-group.stySelect {
            overflow: visible;
        }

        .form-material button.form-control {
            padding: .8rem 25px .8rem 1.2rem;
            border: 1px solid #e4e7ea;
        }

        .dropify-wrapper {
            border: 0;
        }

    </style>
@endsection
@section('main')
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <div class="row">
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-md-12">医师姓名</label>
                                    <div class="col-md-12">
                                        <input type="text" value="{{ $doctor->person_name }}" name="person_name"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-md-12">所属商户</label>
                                    <div class="col-md-12">
                                        <input type="text"
                                               value="{{ \App\ShopInfo::where('id', $doctor->shid)->value('store_name') }}"
                                               name="shid"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label class="col-md-12">医师性别</label>
                                    <div class="col-md-12">
                                        <input type="text" value="{{ \App\Doctor::$SexDisplay[$doctor->sex] }}"
                                               name="sex"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="form-group">
                                    <label class="col-md-12">医师年龄</label>
                                    <div class="col-md-12">
                                        <input type="text" value="{{ $doctor->age }}"
                                               name="age"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-md-12">医师主治</label>
                                    <div class="col-md-12">
                                        <input type="text"
                                               value="{{ \App\DoctorType::where('id', $doctor->type)->value('title') }}"
                                               name="type"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-md-12">擅长领域</label>
                                    <div class="col-md-12">
                                        <input type="text"
                                               value="{{ \App\DoctorExpert::DoctorExperts($doctor->expert) }}"
                                               name="sex"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">头像</label>
                            <div class="col-md-12">
                                <img src="{{ $doctor->avatar }}" width="100%">
                            </div>
                        </div>
                    </div>
                    @if($doctor->status == \App\Doctor::STATUS_WAITING)
                        <div class="col-md-4">
                            <label class="col-md-12">信息审核</label>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-on">审核通过
                            </button>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-off">审核不通过
                            </button>
                        </div>
                    @endif
                    <div class="col-md-12">
                        <div class="form-group">
                            <label class="col-md-12">简介</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->introduction }}"
                                       name="introduction"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">注册手机号</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->login_phone }}"
                                       name="login_phone"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">身份证号</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->id_card }}"
                                       name="id_card"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">资格证号</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->qualification }}"
                                       name="qualification"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-1">
                        <div class="form-group">
                            <label class="col-md-12">图文价格</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->picconsult }}"
                                       name="picconsult"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-1">
                        <div class="form-group">
                            <label class="col-md-12">语音价格</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->videoconsult }}"
                                       name="videoconsult"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-1">
                        <div class="form-group">
                            <label class="col-md-12">视频价格</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $doctor->videoconsult }}"
                                       name="videoconsult"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    {{--<div class="col-md-1">--}}
                        {{--<div class="form-group">--}}
                            {{--<label class="col-md-12">沟通方式</label>--}}
                            {{--<div class="col-md-12">--}}
                                {{--<input type="text" value="{{ \App\Doctor::$BuyTypeDisplay[$doctor->buytype] }}"--}}
                                       {{--name="buytype"--}}
                                       {{--class="form-control form-control-line" readonly>--}}
                            {{--</div>--}}
                        {{--</div>--}}
                    {{--</div>--}}
                </div>

                <div class="row">
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">身份证正面</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $doctor->card_up }}"><img src="{{ $doctor->card_up }}" width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">身份证背面</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $doctor->card_down }}"><img src="{{ $doctor->card_down }}"
                                                                        width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">资格证图</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $doctor->qualificationpic }}"><img src="{{ $doctor->qualificationpic }}"
                                                                               width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">其他</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $doctor->otherpic }}"><img src="{{ $doctor->otherpic }}" width="100%"/></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    {{--是否有待审核的新信息--}}
    @if($doctor->status == \App\Doctor::STATUS_NEW)
        <div class="white-box">
            <div class="row">
                <div class="col-md-6">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-12">医师姓名</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $info->person_name }}" name="person_name"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="col-md-12">医师性别</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ \App\Doctor::$SexDisplay[$info->sex] }}" name="sex"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="col-md-12">医师年龄</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ $info->age }}"
                                           name="age"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <label class="col-md-12">医师主治</label>
                                <div class="col-md-12">
                                    <input type="text"
                                           value="{{ \App\DoctorType::where('id', $info->type)->value('title') }}"
                                           name="type"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-md-12">擅长领域</label>
                                <div class="col-md-12">
                                    <input type="text" value="{{ \App\DoctorExpert::DoctorExperts($info->expert) }}"
                                           name="sex"
                                           class="form-control form-control-line" readonly>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>


                <div class="col-md-2">
                    <div class="form-group">
                        <label class="col-md-12">头像</label>
                        <div class="col-md-12">
                            <img src="{{ $info->avatar }}" width="100%">
                        </div>
                    </div>
                </div>
                <div class="col-md-4">
                    <label class="col-md-12">信息审核</label>
                    <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-on">审核通过
                    </button>
                    <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-off">审核不通过
                    </button>
                </div>
                <div class="col-md-12">
                    <div class="form-group">
                        <label class="col-md-12">简介</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->introduction }}"
                                   name="introduction"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label class="col-md-12">身份证号</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->id_card }}"
                                   name="id_card"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label class="col-md-12">资格证号</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->qualification }}"
                                   name="qualification"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-1">
                    <div class="form-group">
                        <label class="col-md-12">图文价格</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->picconsult }}"
                                   name="picconsult"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-1">
                    <div class="form-group">
                        <label class="col-md-12">语音价格</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->videoconsult }}"
                                   name="videoconsult"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
                <div class="col-md-1">
                    <div class="form-group">
                        <label class="col-md-12">视频价格</label>
                        <div class="col-md-12">
                            <input type="text" value="{{ $info->videoconsult }}"
                                   name="videoconsult"
                                   class="form-control form-control-line" readonly>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-3 col-sm-3">
                    <label class="col-md-12">身份证正面</label>
                    <div class="col-md-12">
                        <div class="form-group ">
                            <a class="btn default btn-outline image-popup-vertical-fit"
                               href="{{ $info->card_up }}"><img src="{{ $info->card_up }}" width="100%"/></a>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-sm-3">
                    <label class="col-md-12">身份证背面</label>
                    <div class="col-md-12">
                        <div class="form-group ">
                            <a class="btn default btn-outline image-popup-vertical-fit"
                               href="{{ $info->card_down }}"><img src="{{ $info->card_down }}" width="100%"/></a>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-sm-3">
                    <label class="col-md-12">资格证图</label>
                    <div class="col-md-12">
                        <div class="form-group ">
                            <a class="btn default btn-outline image-popup-vertical-fit"
                               href="{{ $info->qualificationpic }}"><img src="{{ $info->qualificationpic }}"
                                                                         width="100%"/></a>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-sm-3">
                    <label class="col-md-12">其他</label>
                    <div class="col-md-12">
                        <div class="form-group ">
                            <a class="btn default btn-outline image-popup-vertical-fit"
                               href="{{ $info->otherpic }}"><img src="{{ $info->otherpic }}" width="100%"/></a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    @endif
@endsection
@section('js')
    @parent

    <script type="text/javascript">

        // js 获取字符串中最后一个斜杠前面的内容
        function geturlid() {
            var htmlHref = window.location.href;
            htmlHref = htmlHref.replace(/^http:\/\/[^/]+/, "");
            var addr = htmlHref.substr(htmlHref.lastIndexOf('/', htmlHref.lastIndexOf('/') - 1) + 1);
            var index = addr.lastIndexOf("\/");
            //js 获取字符串中最后一个斜杠后面的内容
            var addrLast = decodeURI(addr.substring(index + 1, addr.length));
            return addrLast;
        }


        $('#status-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/doctor/statusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#status-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/doctor/statusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });


        $('#new-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/doctor/newStatusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#new-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/doctor/newStatusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
    </script>
@endsection